<?php 
require_once("../../resources/commons.php");
require_once("../../data/Expense.php");

SessionManager::getInstance()->checkSession();
$l_expenseId=base64_decode($_REQUEST["id"]);
$expense=Expense::getFromPrimaryKey($l_expenseId);

//Only the creator of the expense can delete it
if(SessionManager::getInstance()->getCurrentLoggedUserId() == $expense->getUser_id()){
	$expense->delete();
}

HTTP::redirect("manage_expenses.php");
?>